<template>
  <div class="my">
    <div class="top">
      <div class="userbox">
        <div class="left">
          <h3 class="t1">{{ userInfo.nickname }}</h3>
          <p class="t2">{{ userInfo.intro }}</p>
        </div>
        <div class="right">
          <img
            class="imgicon"
            @click="setuserinfo"
            :src="userInfo.avatar"
            alt=""
          />
        </div>
      </div>
      <ul>
        <li>
          <p>{{ userInfo.submitNum }}</p>
          <p>累计答题</p>
        </li>
        <li>
          <p>{{ userInfo.collectQuestions.length }}</p>
          <p>收藏题目</p>
        </li>
        <li>
          <p>{{ userInfo.errorNum }}</p>
          <p>我的错题</p>
        </li>
        <li>
          <p>{{ percentage }} <span>%</span></p>
          <p>正确率</p>
        </li>
      </ul>
    </div>

    <div class="buttom">
      <MMcell
        icon="iconicon_mine_gangwei"
        @click="clickCell"
        title="我的岗位"
        :value="userInfo.position"
        class="top-cell"
      >
      </MMcell>
      <div class="facedata">
        <div class="t3">面经数据</div>
        <ul>
          <li>
            <span
              >昨日阅读
              <span>+{{ userInfo.shareData.read.yesterday }}</span></span
            >
            <h2>{{ userInfo.shareData.read.total }}</h2>
            <p>阅读总数</p>
          </li>
          <li>
            <span
              >昨日获赞
              <span>+{{ userInfo.shareData.star.yesterday }}</span></span
            >
            <h2>{{ userInfo.shareData.star.total }}</h2>
            <p>获赞总数</p>
          </li>
          <li>
            <span
              >昨日评论
              <span>+{{ userInfo.shareData.comment.yesterday }}</span></span
            >
            <h2>{{ userInfo.shareData.comment.total }}</h2>
            <p>评论总数</p>
          </li>
        </ul>
      </div>
      <van-cell-group>
        <MMcell icon="iconicon_mine_mianjing" title="我的面经分享" value="">
        </MMcell>
        <MMcell
          icon="iconicon_mine_xiaoxi"
          title="我的消息"
          :value="userInfo.systemMessages"
        >
        </MMcell>
        <MMcell
          icon="iconicon_mine_tikushoucang"
          title="收藏的题库"
          :value="userInfo.collectArticles.length"
          v-if="userInfo != ''"
        >
        </MMcell>
        <MMcell icon="iconicon_mine_qiyeshoucang" title="收藏的企业" value="">
        </MMcell>
        <MMcell
          icon="iconicon_mine_cuoti"
          title="我的错题"
          :value="userInfo.errorNum"
        >
        </MMcell>
        <MMcell
          icon="iconbtn_shoucang_sel"
          title="我收藏的错题"
          :value="userInfo.errorQuestions.length"
          v-if="userInfo != ''"
        >
        </MMcell>
      </van-cell-group>
    </div>
  </div>
</template>

<script>
// import MMcell from '@/components/MMcelll'
import { mapState } from 'vuex'
export default {
  name: 'my',
  // components: {
  //   MMcell
  // },
  created () {
    window.console.log(mapState(['userInfo']))
  },
  computed: {
    // userInfo () {
    //   return this.$store.state.userInfo
    // }
    ...mapState(['userInfo']),
    percentage () {
      return (
        ((this.userInfo.submitNum - this.userInfo.errorNum) /
          this.userInfo.errorNum) *
        100
      ).toFixed(1)
    }
  },
  methods: {
    setuserinfo () {
      this.$router.push('/UserInfo')
    },
    clickCell () {
      alert('1111')
    }
  }
}
</script>

<style lang="less">
.my {
  background-color: #f9f9f9;
  padding: 30px 15px;
  .top {
    height: 260px;
    background: linear-gradient(45deg, #ce0031, #b8002c);
    margin: -30px -15px;
    padding: 30px 15px;
    .userbox {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 28px;
      .left {
        .t1 {
          font-size: 21px;
          font-family: PingFangSC, PingFangSC-Semibold;
          color: @white-color;
        }
        .t2 {
          opacity: 0.7;
          font-size: 12px;
          font-family: PingFangSC, PingFangSC-Regular;
          font-weight: 400;
          text-align: left;
          color: @white-color;
        }
      }
      .right {
        .imgicon {
          width: 50px;
          height: 50px;
          border: 2px solid @white-color;
          border-radius: 50%;
        }
      }
    }
    ul {
      display: flex;
      justify-content: space-around;
      align-items: center;
      li {
        p {
          text-align: center;
          margin: 0;
          // 第一个子元素
          // & 去除生成的空格
          &:first-child {
            font-size: 21px;
            color: @white-color;
            margin-bottom: 4px;
          }
          // 最后一个子元素
          &:last-child {
            opacity: 0.7;
            font-size: 12px;
            color: @white-color;
          }
          span {
            font-size: 12px;
            color: @white-color;
          }
        }
      }
    }
  }
  .buttom {
    .top-cell {
      min-height: 55px;
      border-radius: 8px;
      margin-bottom: 10px;
    }
    .facedata {
      width: 345px;
      height: 143px;
      background-color: @white-color;
      border-radius: 8px;
      padding: 19px 15px;
      margin-bottom: 11px;
      .t3 {
        font-size: 14px;
        font-family: PingFangSC, PingFangSC-Semibold;
        font-weight: 600;
      }
      ul {
        display: flex;
        justify-content: space-between;
        li {
          span {
            font-size: 10px;
            font-family: PingFangSC, PingFangSC-Regular;
            font-weight: 400;
            text-align: center;
            color: #b4b4bd;
            span {
              color: #00b8d4;
            }
          }
          h2 {
            height: 24px;
            font-size: 21px;
            font-family: DINAlternate, DINAlternate-Bold;
            font-weight: 700;
            text-align: center;
          }
          p {
            font-size: 12px;
            font-family: PingFangSC, PingFangSC-Regular;
            font-weight: 400;
            text-align: center;
            color: #545671;
          }
        }
      }
    }
    .van-cell-group {
      border-radius: 8px;
      margin-bottom: 10px;
      overflow: hidden;
      .MMcell {
        &::after {
          // 设置线段的颜色为透明
          border-color: transparent;
        }
      }
    }
  }
}
</style>
